package com.student.flink.workcount;

import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * 流处理
 */
public class StreamWordCount {
    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStream<String> text = WordCountData.getDataSet(env);
        DataStream<Tuple2<String,Integer>> counts = text.flatMap(new Tokenizer()).keyBy(0,1).sum(1);
        counts.print();
        env.execute("Streaming WordCount");
    }
}
